package cn.hxth.dubbo.customer.request;

import cn.hxth.api.model.ProductBaseInfo;
import cn.hxth.api.request.Request;
import cn.hxth.api.service.IProductBaseInfoService;

public class ProductBaseInfoDBUpdateRequest extends Request {

	/**
	 * 商品库存
	 */
	private ProductBaseInfo productBaseInfo;
	/**
	 * 商品库存Service
	 */
	private IProductBaseInfoService productBaseInfoService;
	
	public ProductBaseInfoDBUpdateRequest(ProductBaseInfo productBaseInfo,
			IProductBaseInfoService productBaseInfoService) {
		this.productBaseInfo = productBaseInfo ;
		this.productBaseInfoService = productBaseInfoService ;
	}

	public ProductBaseInfoDBUpdateRequest() {
	}

	@Override
	public void process() {
		System.out.println("===========日志===========: 数据库更新请求开始执行，商品id=" + productBaseInfo.getPid() + ", 商品库存数量=" + productBaseInfo.getInventory());
		this.productBaseInfoService.removeProductBaseInfoCache(productBaseInfo);
		this.productBaseInfoService.updateProductBaseInfo(productBaseInfo) ;
	}
	
	/**
	 * 获取商品id
	 */
	public long getPid() {
		return productBaseInfo.getPid() ;
	}

	@Override
	public boolean isForceRefresh() {
		return false;
	}
	
}
